<template>
  <div></div>
</template>
<script>
import { exportData } from "@/api/leps";
import { downloadFile } from "@/api/file";
export default {
  data() {
    return {};
  },
  methods: {
    exportData() {
      exportData({ moduleCode: this.moduleCode }).then((res) => {
        if (!res || !res.id) return;

        let fileId = res.id;
        let fileName = res.fileName + res.fileExtension;
        let contentType = res.contentType;

        downloadFile({ id: fileId }).then((res) => {
          let blob = new Blob([res], {
            type: contentType,
          });
          let link = document.createElement("a");
          link.href = window.URL.createObjectURL(blob);
          link.download = fileName;
          link.click();

          window.URL.revokeObjectURL(link.href);
        });
      });
    },
  },
  mounted() {},
  props: {
    moduleCode: {
      type: String,
    },
  },
};
</script>
<style scoped></style>
